import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Switch, Route, Redirect } from 'react-router-dom';
import { homeRoutes } from './router';
//redux方式 store={store}
import { Provider } from 'react-redux';
// import store from './store';
//redux-Toolkie方式 store={store}
import store from './reduxToolkitStore/store';
//mobx方式  {...store}
// import store from './mobxStore';
// import { Provider } from 'mobx-react';

import './index.css';
import Admin from './config/admin';
import User from './config/user';
// import 'antd/dist/antd.css';
import './i18n/config'; //国际化
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
  <Provider store={store}>
    <Router>
      <Switch>
        <Route path="/admin" render={routeProps => <Admin {...routeProps} />} />
        <Route path="/user" render={routeProps => <User {...routeProps} />} />
        {homeRoutes.map((route, index) => {
          return <Route exact key={index} path={route.path} component={route.component} />;
        })}
        <Redirect path="/" to="/login" />
        <Redirect to="/404" />
      </Switch>
    </Router>
  </Provider>,

  document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
